#include <math.h>
int main() 
{
	int i = 0;
	for (i = 0; i <= 100000; i++) {
		int count = 1; 
		int temp = i;
		while (temp /= 10) 
		{
			count++;
		}
		temp = i;
		int sum = 0;
		while (temp) 
		{
			sum += pow(temp % 10, count);
			temp /= 10;
		}
		if (i == sum) {
			printf("%d\n", i);
		}
	}
	return 0;
}

